home *** CD-ROM | disk | FTP | other *** search
- 10 'SOLUTION.BAS - One possible solution to the GWBT09 homework assignment!
- 20 'NO PEEKING unless you're done or REALLY STUCK!
- 30 '
- 40 'Our data to be used is as follows:
- 50 '
- 60 'Last Name: 15 characters
- 70 'First Name: 15 characters
- 80 'Address: 20 characters
- 90 'City: 10 characters
- 100 'State: 10 characters
- 110 'ZIP code: 10 characters
- 120 'Phone number: 13 characters
- 130 'Comments: 35 characters
- 140 '
- 150 'First, we need to open the file and FIELD it so BASIC knows about it...
- 160 '
- 170 OPEN "ADDRESS.DAT" FOR RANDOM AS #1 LEN=128
- 180 FIELD #1,15 AS LASTNAME$,15 AS FIRSTNAME$,20 AS ADDRESS$,10 AS CITY$,10 AS STATE$,10 AS ZIP$,13 AS PHONE$,35 AS COMMENT$
- 190 LASTREC=LOF(1)/128
- 200 'IMPORTANT - You need to be sure that the number of characters in your FIELD
- 210 'statment adds up to the length you told BASIC in the LEN above, otherwise
- 220 'you will get all sorts of interesting errors...
- 230 '
- 240 'Start getting information here...
- 250 KEY OFF:CLS
- 260 INPUT "Enter a 'Y' to put information in, or 'N' to quit";ANSWER$
- 270 IF ANSWER$="Y" OR ANSWER$="y" THEN GOTO 300
- 280 'Actually, any answer EXCEPT 'Y' will end the program...
- 290 CLOSE:RESET:END
- 300 '
- 310 'Enter information and save to disk...
- 320 PRINT
- 330 PRINT "For the address/phone card you are entering, please answer the "
- 340 PRINT "following questions:"
- 350 PRINT
- 360 INPUT "What is the LAST NAME";LSTNAME$
- 370 PRINT
- 380 INPUT "What is the FIRST NAME";FSTNAME$
- 390 PRINT
- 400 INPUT "What is the STREET ADDRESS";STADDRESS$
- 410 PRINT
- 420 INPUT "What is the CITY";CTY$
- 430 PRINT
- 440 INPUT "What is the STATE";STE$
- 450 PRINT
- 460 INPUT "What is the ZIP CODE";ZC$
- 470 PRINT
- 480 INPUT "What is the PHONE NUMBER";PH$
- 490 PRINT
- 500 INPUT "What COMMENTS should I add";COMM$
- 510 PRINT
- 520 '
- 530 'Ready to save to disk. Add one to the last record counter, use LSET to put
- 540 'the answers where they need to be, then write it out...
- 550 '
- 560 LASTREC=LASTREC+1
- 570 LSET LASTNAME$=LSTNAME$
- 580 LSET FIRSTNAME$=FSTNAME$
- 590 LSET ADDRESS$=STADDRESS$
- 600 LSET CITY$=CTY$
- 610 LSET STATE$=STE$
- 620 LSET ZIP$=ZC$
- 630 LSET PHONE$=PH$
- 640 LSET COMMENT$=COMM$
- 650 '
- 660 'Write the record to disk and see if there are any more...
- 670 '
- 680 PUT #1,LASTREC
- 690 GOTO 250
- 700 END
- 710 'End of program SOLUTION.BAS from GWBT09 02/01/1991